package dto;
// Generated Mar 20, 2013 5:08:51 PM by Hibernate Tools 3.2.1.GA

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 * Product generated by hbm2java
 */
@Entity
@Table(name = "Product", schema = "dbo", catalog = "AntiqueShop")
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement
public class Product implements java.io.Serializable {
    @XmlAttribute(name="id", required=true)
    private int id;
//    @XmlTransient
    @XmlElement(name="category", required=true)
    private Category category;
    @XmlElement(name="name", required=true)
    private String name;
    @XmlElement(name="description", required=true)
    private String description;
    @XmlElement(name="price", required=true)
    private double price;
    @XmlElement(name="quantity", required=true)
    private int quantity;
    @XmlElement(name="createdate", required=false)
    private Date createDate;
    @XmlElement(name="updatedate", required=false)
    private Date updateDate;
    @XmlElement(name="isdeleted", required=true)
    private boolean isDeleted;
    @XmlElement(name="isshowed", required=true)
    private boolean isShowed;
    @XmlTransient
    private List<OrderItems> orderItemses = new ArrayList<OrderItems>();

    @XmlElementWrapper(name="images")
    @XmlElement(name="image", required=false)
    private List<Image> images = new ArrayList<Image>();

    public Product() {
    }

    public Product(int id, Category category, String name, String description, double price, int quantity, boolean isDeleted, boolean isShowed) {
        this.id = id;
        this.category = category;
        this.name = name;
        this.description = description;
        this.price = price;
        this.quantity = quantity;
        this.isDeleted = isDeleted;
        this.isShowed = isShowed;
    }

    public Product(int id, Category category, String name, String description, double price, int quantity, Date createDate, Date updateDate, boolean isDeleted, boolean isShowed, List<OrderItems> orderItemses, List<Image> images) {
        this.id = id;
        this.category = category;
        this.name = name;
        this.description = description;
        this.price = price;
        this.quantity = quantity;
        this.createDate = createDate;
        this.updateDate = updateDate;
        this.isDeleted = isDeleted;
        this.isShowed = isShowed;
        this.orderItemses = orderItemses;
        this.images = images;
    }

    @Id
    @GeneratedValue(strategy=GenerationType.IDENTITY)
    @Column(name = "id", unique = true, nullable = false)
    public int getId() {
        return this.id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "category_id", nullable = false)
    public Category getCategory() {
        return this.category;
    }

    public void setCategory(Category category) {
        this.category = category;
    }

    @Column(name = "name", nullable = false)
    public String getName() {
        return this.name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Column(name = "description", nullable = false)
    public String getDescription() {
        return this.description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    @Column(name = "price", nullable = false, precision = 53, scale = 0)
    public double getPrice() {
        return this.price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    @Column(name = "quantity", nullable = false)
    public int getQuantity() {
        return this.quantity;
    }

    public void setQuantity(int quantity) {
        this.quantity = quantity;
    }

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "create_date", length = 23)
    public Date getCreateDate() {
        return this.createDate;
    }

    public void setCreateDate(Date createDate) {
        this.createDate = createDate;
    }

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "update_date", length = 23)
    public Date getUpdateDate() {
        return this.updateDate;
    }

    public void setUpdateDate(Date updateDate) {
        this.updateDate = updateDate;
    }

    @Column(name = "is_deleted", nullable = false)
    public boolean isIsDeleted() {
        return this.isDeleted;
    }

    public void setIsDeleted(boolean isDeleted) {
        this.isDeleted = isDeleted;
    }

    @Column(name = "is_showed", nullable = false)
    public boolean isIsShowed() {
        return this.isShowed;
    }

    public void setIsShowed(boolean isShowed) {
        this.isShowed = isShowed;
    }

    @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "product")
    public List<OrderItems> getOrderItemses() {
        return this.orderItemses;
    }

    public void setOrderItemses(List<OrderItems> orderItemses) {
        this.orderItemses = orderItemses;
    }

    @OneToMany(fetch = FetchType.EAGER, mappedBy = "product", cascade = CascadeType.ALL)
    public List<Image> getImages() {
        return this.images;
    }

    public void setImages(List<Image> images) {
        this.images = images;
    }
}
